#include <cstdio>
#include <cstring>

//0: A   1: B   2: C
char DIGIT[3][4];
int LEN[3];

char ch[] = {'*', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
int depth;

int get_digit(int n) {
    int result = 0;
    for (int i=0; i<LEN[n]; i++) {
        result *= 10;
        result += DIGIT[n][i]-'0';
    }
    return result;
}

bool check_digit() {
    int a=0, b=0, c=0;
    a = get_digit(0);
    b = get_digit(1);
    c = a*b;
    //printf("%d %d %d\n", a, b, c);
    //////////////////////////////
    int i = LEN[2]-1;
    while (c && i >= 0) {
        int d = c % 10;
        if (DIGIT[2][i] != d+'0' && DIGIT[2][i] != '*') return false;
        c /= 10;
        i--;
    }
    if (c || i >= 0) return false;
    //printf("true\n");
    return true;
}

int check(int a, int b) {
    if (a >= 2) {
        if (check_digit())
            return 1;
        return 0;
    }
    if (b >= LEN[a]) {
        return check(a+1, 0);
    }
    /////////////////////////////////
    int sum = 0;
    if (DIGIT[a][b] == '*') {
        for (int i=1; i<11; i++) {
            if (b == 0 && i == 1) continue;
            DIGIT[a][b] = ch[i];
            int t = check(a, b+1);
            DIGIT[a][b] = '*';
            if (t<0) {
                sum = -1;
                break;
            }
            sum += t;
            if (sum > 1) {
                sum = -1;
                break;
            }
        }
    } else {
        int t = check(a, b+1);
        if (t<0 || t>1) {
            sum = -1;
        } else {
            sum = t;
        }
    }
    return sum;
}

void print() {
    bool first = true;
    for (int i=0; i<3; i++) {
        if (first) first = false;
        else printf(" ");
        for (int j=0; j<LEN[i]; j++) {
            printf("%c", DIGIT[i][j]);
        }
    }
    printf("\n");
}

bool dfs(int n, int a, int b) {
    if (n > depth) {
        if (check(0, 0) == 1) {
            print();
            return true;
        }
        return false;
    }
    if (a >= 3) {
        return false;
    }
    if (b >= LEN[a]) {
        return dfs(n, a+1, 0);
    }
    char orig = DIGIT[a][b];
    for (int i=0; i<11; i++) {
        if (orig == ch[i]) {
            DIGIT[a][b] = orig;
            if (dfs(n, a, b+1))
                return true;
            continue;
        }
        if (b == 0 && i == 1) continue;
        DIGIT[a][b] = ch[i];
        if (dfs(n+1, a, b+1))
            return true;
    }
    DIGIT[a][b] = orig;
    return false;
}

int main() {
    int T = 0;
    while (true) {
        int depthsum = 0;
        memset(DIGIT, 0, sizeof(DIGIT));
        char buf[10];
        for (int i=0; i<3; i++) {
            scanf("%s", buf);
            if (i == 0 && buf[0] == '0')
                goto end;
            LEN[i] = strlen(buf);
            depthsum += LEN[i];
            for (int j=0; j<LEN[i]; j++) {
                DIGIT[i][j] = buf[j];
            }
        }
        //printf("%d\n", check(0, 0));
        printf("Case %d: ", ++T);
        if (check(0, 0) == 1) {
            print();
            continue;
        }
        for (depth = 1; depth <= depthsum; depth++) {
            if (dfs(1, 0, 0)) {
                break;
            }
        }
    }
    end:
    return 0;
}
